package com.chen.springboot.controller.dto;

import com.chen.springboot.entity.User;
import lombok.Data;
//将USER实体的数据转化为可以传输给前端的数据（避免直接将实体对象暴露给前段，更安全）
// User的 Data Transfer Object 数据传输转换对象
@Data
public class UserDto {
    private Integer id;
    private String username;
    private String password;
    private String nickName;
    private Integer age;
    private String avatar;
    private String sex;
    private int role;
    private String token;

    public UserDto(User user, String token) {
        this.id = user.getId();
        this.username = user.getUsername();
        this.password = user.getPassword();
        this.nickName = user.getNickName();
        this.age = user.getAge();
        this.avatar = user.getAvatar();
        this.sex = user.getSex();
        this.role = user.getRole();
        this.token = token;
    }
}
